﻿Imports Sy.Data

Public Class Response
    Inherits JsonObject(Of Response)
    Private Shared ReadOnly Empty As Response = New Response(StateCode.Analysis)
    Public Sub New()
    End Sub
    Private Sub New(Code As String)
        Me.Code = Code
    End Sub
    Public Property Code As Integer
    Public Property Data As String
    Public Shared Function Analysis(rsp As String) As Response
        Dim RspRow = DeserializeSafety(rsp)
        Return If(RspRow, Empty)
    End Function
End Class
Public Enum StateCode
    <Description("数据解析出错")>
    <Description("zh-CN", "数据解析出错")>
    <Description("en-US", "Data parsing error")>
    Analysis = 100
    ''' <summary>
    ''' 成功
    ''' </summary>
    <Description("成功")>
    <Description("zh-CN", "成功")>
    <Description("en-US", "success")>
    Success = 1000
    ''' <summary>
    ''' 版本校验不通过
    ''' </summary>
    <Description("版本校验不通过")>
    <Description("zh-CN", "版本校验不通过")>
    <Description("en-US", "Version verification failed")>
    Version = 1001
    ''' <summary>
    ''' 字段不合法(Json反序列化出错)
    ''' </summary>
    <Description("字段不合法")>
    <Description("zh-CN", "字段不合法")>
    <Description("en-US", "Invalid field")>
    Field = 1002
    ''' <summary>
    ''' 参数有误(缺少Action必需参数)
    ''' </summary>
    <Description("参数有误")>
    <Description("zh-CN", "参数有误")>
    <Description("en-US", "Incorrect parameters")>
    Parameter = 1003
    ''' <summary>
    ''' 用户未登陆
    ''' </summary>
    <Description("用户未登陆")>
    <Description("zh-CN", "用户未登陆")>
    <Description("en-US", "User not logged in")>
    User = 1004
    <Description("服务器未实现")>
    <Description("zh-CN", "服务器未实现")>
    <Description("en-US", "Server not implemented")>
    NotImpt = 1005
    <Description("未知错误")>
    <Description("zh-CN", "未知错误")>
    <Description("en-US", "unknown mistake")>
    Unknow = 9999
End Enum